//添加博客

function sumbit() {
    if ($("#introduction").val() !== "" && $("#keyword").val() !== "" && editor.txt.html() !== "") {
        let status = $('#status input[name="status"]:checked').val();
        $.ajax({
            url: "/admin/addBlog",
            type: "get",
            async: false,
            dataType: "json",
            data: {
                "title": $("#title").val(),
                "introduction": $("#introduction").val(),
                "keyword": $("#keyword").val(),
                "content": editor.txt.html(),
                "status": status,
                "type_id": $("#type").val(),
                "image": $("#image").val()
            },
            success: function (data) {
                if (data === true) {
                    Swal.fire({
                        title: "添加成功",
                        icon: "success",
                        confirmButtonText: "OK",
                        allowOutsideClick: false,
                    }).then($(".swal2-actions button").click(function () {
                        history.go();
                    }))
                }
            },
            error: function () {
                Swal.fire({
                    icon: 'error',
                    title: '添加失败',
                    allowOutsideClick: false,
                })
                history.go();
            }
        })
    }
}
